package com.csesteel.crm.domain;

import org.hibernate.annotations.*;
import org.hibernate.annotations.Cache;

import javax.persistence.*;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Set;

/**
 * Created by Administrator on 2015/5/20 0020.
 */
@Entity
@Table(name="crm_tb_priviledge")
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
@SequenceGenerator(name="SEQ_CRM_TB_PRIVILEDGE",allocationSize=1,initialValue=1, sequenceName="SEQ_CRM_TB_PRIVILEDGE")
public class CrmPriviledge implements Serializable {
    private static final long serialVersionUID = 48L;
    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE,generator="SEQ_CRM_TB_PRIVILEDGE")
    @Column(name="priviledge_id")
    private Integer priviledgeId;

    @Column(name="priviledge_code")
    private String priviledgeCode;

    @Column(name="priviledge_name")
    private String priviledgeName;

    @Column(name="priviledge_remark")
    private String priviledgeRemark;

//    @OneToMany(cascade = CascadeType.ALL)
//    @JoinTable(name = "crm_r_priviledge_role", joinColumns = { @JoinColumn(name = "priviledge_id", referencedColumnName = "priviledge_id") }, inverseJoinColumns = { @JoinColumn(name = "role_id", referencedColumnName = "role_id") })
//    private Set<CrmRole> priviledgeRoles;
//    @ManyToOne(fetch = FetchType.LAZY)
//    @JoinTable(name = "crm_r_priviledge_role", joinColumns = { @JoinColumn(name = "priviledge_id", referencedColumnName = "priviledge_id") }, inverseJoinColumns = { @JoinColumn(name = "role_id", referencedColumnName = "role_id") })
//    private CrmRole crmRole;
//
//    public CrmRole getCrmRole() {
//        return crmRole;
//    }
//
//    public void setCrmRole(CrmRole crmRole) {
//        this.crmRole = crmRole;
//    }

    @OneToMany(fetch = FetchType.EAGER)
    @JoinTable(name = "crm_r_menu_priviledge", joinColumns = { @JoinColumn(name = "priviledge_id", referencedColumnName = "priviledge_id") }, inverseJoinColumns = { @JoinColumn(name = "menu_id", referencedColumnName = "menu_id") })
    private Set<CrmMenu> priviledgeMenus;

    public Integer getPriviledgeId() {
        return priviledgeId;
    }

    public void setPriviledgeId(Integer priviledgeId) {
        this.priviledgeId = priviledgeId;
    }

    public String getPriviledgeCode() {
        return priviledgeCode;
    }

    public void setPriviledgeCode(String priviledgeCode) {
        this.priviledgeCode = priviledgeCode;
    }

    public String getPriviledgeName() {
        return priviledgeName;
    }

    public void setPriviledgeName(String priviledgeName) {
        this.priviledgeName = priviledgeName;
    }

    public String getPriviledgeRemark() {
        return priviledgeRemark;
    }

    public void setPriviledgeRemark(String priviledgeRemark) {
        this.priviledgeRemark = priviledgeRemark;
    }

//    public Set<CrmRole> getPriviledgeRoles() {
//        return priviledgeRoles;
//    }
//
//    public void setPriviledgeRoles(Set<CrmRole> priviledgeRoles) {
//        this.priviledgeRoles = priviledgeRoles;
//    }

    public Set<CrmMenu> getPriviledgeMenus() {
        return priviledgeMenus;
    }

    public void setPriviledgeMenus(Set<CrmMenu> priviledgeMenus) {
        this.priviledgeMenus = priviledgeMenus;
    }
}
